package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.dto.HospitalAreaQueryDto;
import com.example.demo.entity.pojo.HospitalArea;
import com.example.demo.mapper.HospitalAreaMapper;
import com.example.demo.service.HospitalAreaService;
import jakarta.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
*   @author liye
*   @date 2025/10/9 14:29
*   @description: 
*/
@Service
//@Slf4j   //日志注解
public class HospitalAreaServiceImpl extends ServiceImpl<HospitalAreaMapper, HospitalArea> implements HospitalAreaService {
    @Resource
    private HospitalAreaMapper hospitalAreaMapper;
    //日志对象
    Logger logger= LoggerFactory.getLogger(HospitalAreaServiceImpl.class);
    @Override
    public IPage<HospitalArea> page(HospitalAreaQueryDto queryDto) {
        logger.info("医院的分页查询参数：{}",queryDto);
        //分页
        LambdaQueryWrapper<HospitalArea>  queryWrapper=new LambdaQueryWrapper<>();
        //根据名字模糊查询
        if(queryDto.getAreaName()!=null && queryDto.getAreaName().trim().length()>0) {
            queryWrapper.like(HospitalArea::getAreaName, queryDto.getAreaName());
        }
        Page page = hospitalAreaMapper.selectPage(new Page(queryDto.getPage(),queryDto.getLimit()), queryWrapper);
        return page;
    }
}
